package com.bone.modules.message.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.bone.modules.message.service.IMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.concurrent.Future;

/**
 * @author :
 * @date : 2020/12/29 18:19
 * Description :
 */
@Component
@Slf4j
public class MessageServiceImpl implements IMessageService {


    @Override
    public Future<String> sendMessage(String message) {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("消息内容: {}", message);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("thread", Thread.currentThread().getName());
        jsonObject.put("time", System.currentTimeMillis());
        return new AsyncResult<>(jsonObject.toJSONString());
    }
}
